package org.catdroid.spora.html;

import java.io.IOException;

import org.catdroid.spora.XPaths;
import org.catdroid.spora.bean.Locations;
import org.catdroid.spora.bean.Location;
import org.htmlcleaner.XPatherException;



public class DataHarvester {
	private GetHtmlContent	page;

	public DataHarvester (String url) throws IOException {
		page = new GetHtmlContent(url);
	}
	
	public Locations getLocations () 
	{
		Locations locations=new Locations();
		String[] unparsedLocations;
		try {
			unparsedLocations = page.getTextArray(XPaths.locationsHeaders);
		} catch (XPatherException e) {
			return null;
		}
		int items=unparsedLocations.length;
		for (int i=1;i<items;i++) {
			locations.add(new Location(i-1,unparsedLocations[i]));
		}
		return locations;
	}
}
